package com.com.hefei.wdp.example.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ProducerController {
    @Autowired
    private DiscoveryClient discoveryClient;


    @Value("${server.port}")
    private Integer port;

    @Value("${spring.application.name}")
    private String SpringApplicationName;


    @GetMapping("/serviceInfo")
    public String getServiceInfo(){
        discoveryClient.getServices();
        discoveryClient.description();
        discoveryClient.getOrder();
        return SpringApplicationName+" : "+port;
    }

    @GetMapping("/appInfo")
    public String getAppInfo(){
        return SpringApplicationName+" : "+port;
    }

    @GetMapping("/hello")
    public String hello(){
        return "Hello！I'm a. port：" + port;
    }

    @GetMapping("/name")
    public String name(String name){
        return "My name is " + name + ". aaa";
    }

    /*
     * @ClassName ASayHelloController
     * @Desc TODO   接收从网关传入的参数
     * @Date 2019/6/23 16:52
     * @Version 1.0
     */
    @GetMapping("/age")
    public String age(String age){
        return "I am " + age + " years old this year. aaa";
    }

    /*
     * @ClassName ASayHelloController
     * @Desc TODO   接收从网关传入的参数
     * @Date 2019/6/29 22:00
     * @Version 1.0
     */
    @GetMapping("/routeAll")
    public String routeAll(String pass) {
        return "Can I pass? " + pass + "! port：" + port;
    }



}
